import 'package:flutter/material.dart';

import 'article_detail_controller.dart';
import 'package:blog_chyk_intl/utils/index.dart';

class ArticleDetailView extends StatelessWidget {
  ArticleDetailView({super.key});

  final ArticleDetailController controller = Get.put(ArticleDetailController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('详情'.tr),
        actions: [
          Obx(
            () => IconButton(
              icon: Icon(isDarkMode ? Icons.light_mode : Icons.dark_mode),
              onPressed: toggleThemeGlobal,
            ),
          ),
        ],
      ),
      body: Obx(
        () => controller.isLoading.value
            ? Center(child: CircularProgressIndicator())
            : Padding(
                padding: const EdgeInsets.all(16),
                child: ListView(
                  children: [
                    Text(
                      controller.article.value.title,
                      style: const TextStyle(
                        fontSize: 24,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    const SizedBox(height: 8),
                    Text(
                      controller.article.value.date.toString().substring(0, 10),
                    ),
                    const SizedBox(height: 16),
                    Text(
                      controller.article.value.content,
                      style: const TextStyle(fontSize: 16),
                    ),
                  ],
                ),
              ),
      ),
    );
  }
}
